#include "stdafx.h"
#include "VerifyTask.h"


CVerifyTask::CVerifyTask( const char * szUser, const char * szPwd, TCallback fCallback )
{
    UsrName = szUser;
    Password = szPwd;
    CallbackFunc = fCallback;
    Result = false;
    DigitID = 0;
}

CVerifyTask::~CVerifyTask()
{

}

void CVerifyTask::Callback()
{
    CallbackFunc(UsrName.c_str(), Result, DigitID);
}

void CVerifyTask::DatabaseCallback( utility::database::query_result * res, const utility::database::error_code & ec )
{
    if (!ec)
    {
        if (res != NULL)
        {
            try
            {
                if (!res->empty())
                {
                    DigitID = atoi((*res)[0]["UserId"].c_str());
                    Result = true;
                }
            }
            catch(error_code &)
            {
            }
        }
    }
    Callback();
}

